package controllor;

import com.opensymphony.xwork2.ActionSupport;
import  com.opensymphony.xwork2.ActionContext;
public class LoginAction extends ActionSupport {
    private String ID;
    private String Password;

    public String getID() {
        return ID;
    }

    public void setID(String ID) {
        this.ID = ID;
    }

    public String getPassword() {
        return Password;
    }

    public void setPassword(String Password) {
        this.Password = Password;
    }

    @Override
    public void validate() {
        if (ID.isEmpty()) {
            addFieldError("ID", getText("ID.null"));
        }
        if (Password.isEmpty()) {
            addFieldError("password", getText("Password.null"));
        }
    }
    public String execute() throws Exception{
        if(getID().equals("24")&&getPassword().equals("123")){
            ActionContext.getContext().getSession().put("ID", getID());
            return SUCCESS;
        }else {
            return INPUT;
        }
    }
}
